home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / virtualdub / VirtualDub-source-1_4d / AVIIndex.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-20  |  2.6 KB  |  118 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #ifndef f_AVIINDEX_H
  19. #define f_AVIINDEX_H
  20.  
  21. #include <stdio.h>
  22. #include <string.h>
  23.  
  24. #include <windows.h>
  25. #include <vfw.h>
  26.  
  27. class AVIIndexChainNode;
  28.  
  29. class AVIIndexEntry2 {
  30. public:
  31.     __int64 pos;
  32.     union {
  33.         FOURCC    ckid;
  34.         int        fileno;
  35.     };
  36.     LONG    size;
  37. };
  38.  
  39. class AVIIndexEntry3 {
  40. public:
  41.     DWORD    dwOffset;
  42.     DWORD    dwSizeKeyframe;
  43. };
  44.  
  45. class AVIIndexChain {
  46. protected:
  47.     AVIIndexChainNode *head, *tail;
  48.  
  49.     void delete_chain();
  50. public:
  51.     int total_ents;
  52.  
  53.     AVIIndexChain();
  54.     ~AVIIndexChain();
  55.  
  56.     bool add(AVIINDEXENTRY *avie);
  57.     bool add(AVIIndexEntry2 *avie2);
  58.     bool add(FOURCC ckid, __int64 pos, long len, bool is_keyframe);
  59.     void put(AVIINDEXENTRY *avietbl);
  60.     void put(AVIIndexEntry2 *avie2tbl);
  61.     void put(AVIIndexEntry3 *avie3tbl, __int64 offset);
  62. };
  63.  
  64. class AVIIndex : public AVIIndexChain {
  65. protected:
  66.     AVIINDEXENTRY *index;
  67.     AVIIndexEntry2 *index2;
  68.     AVIIndexEntry3 *index3;
  69.     int index_len;
  70.  
  71.     AVIINDEXENTRY *allocateIndex(int total_entries) {
  72.         return index = new AVIINDEXENTRY[index_len = total_entries];
  73.     }
  74.  
  75.     AVIIndexEntry2 *allocateIndex2(int total_entries) {
  76.         return index2 = new AVIIndexEntry2[index_len = total_entries];
  77.     }
  78.  
  79.     AVIIndexEntry3 *allocateIndex3(int total_entries) {
  80.         return index3 = new AVIIndexEntry3[index_len = total_entries];
  81.     }
  82.  
  83. public:
  84.     AVIIndex();
  85.     ~AVIIndex();
  86.  
  87.     bool makeIndex();
  88.     bool makeIndex2();
  89.     bool makeIndex3(__int64 offset);
  90.     void clear();
  91.  
  92.     AVIINDEXENTRY *indexPtr() {
  93.         return index;
  94.     }
  95.  
  96.     AVIIndexEntry2 *index2Ptr() {
  97.         return index2;
  98.     }
  99.  
  100.     AVIIndexEntry3 *index3Ptr() {
  101.         return index3;
  102.     }
  103.  
  104.     AVIIndexEntry2 *takeIndex2() {
  105.         AVIIndexEntry2 *idx = index2;
  106.  
  107.         index2 = NULL;
  108.         return idx;
  109.     }
  110.  
  111.     int size() { return total_ents; }
  112.  
  113.     int indexLen() {
  114.         return index_len;
  115.     }
  116. };
  117.  
  118. #endif